package com.heima.schedule;

import com.heima.api.ScheduleFeignClient;
import com.heima.model.schedule.dtos.Task;
import com.heima.schedule.service.TaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 安排客户
 *
 * @author DiXiaoNie
 * @date 2022/12/25
 * @since 2022/12/25 11:39
 */
@RestController
@RequestMapping("/api/v1/schedule")
public class ScheduleClient implements ScheduleFeignClient {
    @Resource
    private TaskService taskService;


    /**
     * 添加任务
     *
     * @param task 任务对象
     * @author DiXiaoNie
     * @date 2022/12/24
     */
    @Override
    @PostMapping("/addTask")
    public void addTask(@RequestBody Task task) {
        this.taskService.addTask(task);

    }

    /**
     * 拉取任务
     *
     * @param type     类型
     * @param priority 优先级
     * @author DiXiaoNie
     * @date 2022/12/24
     */
    @Override
    @GetMapping("/pullTask/{type}/{priority}")
    public Task pullTask(@PathVariable("type") Integer type, @PathVariable("priority") Integer priority) {
        return this.taskService.pullTask(type, priority);
    }
}
